package com.cskaoyan.mall25.controller;

import com.cskaoyan.mall25.bean.BaseRespVo;
import com.cskaoyan.mall25.bean.LoginBo;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@RequestMapping("admin/auth")
@RestController
public class LoginController {

    //@RequestMapping(value = "admin/auth/login",method = RequestMethod.POST)
    @PostMapping("login")
    //public BaseRespVo login(@RequestBody LoginBo loginBo){
    public BaseRespVo login(@RequestBody Map map){
        String username = (String) map.get("username");
        String password = (String) map.get("password");
        return BaseRespVo.ok("e76ddbc8-4029-42be-8549-d871d64b44e2");//shiro后可以返回sessionId
    }

    @RequestMapping("info")
    public BaseRespVo info(String token){
        //根据上面login登录后的结果查询该用户的信息
        Integer id = 1;//假定id为某一个值，当其他接口开发完成后，可以改为通过其他接口获得的值
        //查询的过程交给你们
        Map data = new HashMap();
        //引出图片上传和静态资源映射的关系：上传路径和静态资源映射的location可以放到一个路径
        data.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        data.put("name","songge");
        ArrayList<String> roleList = new ArrayList<>();
        roleList.add("超级管理员");
        data.put("roles", roleList);
        ArrayList<String> permList = new ArrayList<>();
        permList.add("*");
        data.put("perms", permList);

        return BaseRespVo.ok(data);
    }
}
